home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DMAKE38B.ARJ / M_PERROR.C < prev    next >
C/C++ Source or Header  |  1992-01-23  |  2KB  |  94 lines

  1. /*
  2.  * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).  
  3.  * You may copy, distribute, and use this software as long as this
  4.  * copyright statement is not removed.
  5.  */
  6.  
  7. #ifndef lint
  8. static
  9. char rcsid[] = "$Id: m_perror.c,v 1.1 1992/01/24 03:29:04 dvadura Exp $";
  10. #endif
  11.  
  12. /*
  13.  * malloc errno error strings...
  14.  */
  15.  
  16. char *malloc_err_strings[] = 
  17. {
  18.     "No errors",
  19.     "Malloc chain is corrupted, pointers out of order",
  20.     "Malloc chain is corrupted, end before end pointer",
  21.     "Pointer is not within malloc area",
  22.     "Malloc region does not have valid magic number in header",
  23.     "Pointers between this segment and ajoining segments are invalid",
  24.     "Data has overrun beyond requested number of bytes",
  25.     "Data in free'd area has been modified",
  26.     "Data are is not in use (can't be freed or realloced)",
  27.     "Unable to get additional memory from the system",
  28.     "Pointer within malloc region, but outside of malloc data bounds",
  29.     (char *) 0
  30. };
  31.  
  32. /*
  33.  * Function:    malloc_perror()
  34.  *
  35.  * Purpose:    to print malloc_errno error message
  36.  *
  37.  * Arguments:    str    - string to print with error message
  38.  *
  39.  * Returns:    nothing of any value
  40.  *
  41.  * Narrative:
  42.  */
  43. void
  44. malloc_perror(str)
  45.     char    * str;
  46. {
  47.     extern int      malloc_errno;
  48.     register char     * s;
  49.     register char     * t;
  50.  
  51.     if( str && *str)
  52.     {
  53.         for(s=str; *s; s++)
  54.         {
  55.             /* do nothing */;
  56.         }
  57.  
  58.         (void) write(2,str,(unsigned)(s-str));
  59.         (void) write(2,": ",(unsigned)2);
  60.     }
  61.  
  62.     t = malloc_err_strings[malloc_errno];
  63.  
  64.     for(s=t; *s; s++)
  65.     {
  66.         /* do nothing */;
  67.     }
  68.  
  69.     (void) write(2,t,(unsigned)(s-t));
  70.  
  71.     (void) write(2,"\n",(unsigned)1);
  72. }
  73.  
  74. /*
  75.  * $Log: m_perror.c,v $
  76.  * Revision 1.1  1992/01/24  03:29:04  dvadura
  77.  * dmake Version 3.8, Initial revision
  78.  *
  79.  * Revision 1.5  90/08/29  21:25:08  cpcahil
  80.  * added additional error message that was missing (and 
  81.  * caused a core dump)
  82.  * 
  83.  * Revision 1.4  90/05/11  00:13:08  cpcahil
  84.  * added copyright statment
  85.  * 
  86.  * Revision 1.3  90/02/24  21:50:21  cpcahil
  87.  * lots of lint fixes
  88.  * 
  89.  * Revision 1.2  90/02/24  17:39:55  cpcahil
  90.  * 1. added function header
  91.  * 2. added rcs id and log strings.
  92.  * 
  93.  */
  94.